// to compile: g++ -I/Users/minhdt/Documents/Study/libs testPartialBeliefSet.cpp 

#include <iostream>
#include "bm3.7.0/src/bm.h"

typedef bm::bvector<> BitMagic;

class BeliefSet
{
public:
  // for 3-value assignment
  enum TruthVal
    {
      FALSE = 0,
      TRUE,
      UNDEF
    };

  BeliefSet()
  {
    value_bit = new BitMagic;
    state_bit = new BitMagic;
  }

  BeliefSet(std::size_t n)
  {
    assert (n > 0);

    value_bit = new BitMagic;
    state_bit = new BitMagic;

    value_bit->resize(n);
    state_bit->resize(n);
  }

  ~BeliefSet()
  {
    delete value_bit;
    delete state_bit;
  }

  // get the truth value of bit n
  TruthVal
  test(std::size_t n)
  {
    assert (n > 0 && n < value_bit->size());

    if (state_bit->test(n))
      {
	if (value_bit->test(n))
	  {
	    return TRUE;
	  }
	else
	  {
	    return FALSE;
	  }
      }

    return UNDEF;
  }

  bool
  isEpsilon()
  {
    return !(state_bit->test(0));
  }

  void
  setEpsilon()
  {
    state_bit->set(0);
  }

  // set the truth value of bit n
  void
  set(std::size_t n, TruthVal val = TRUE)
  {
    assert (n > 0 && n < value_bit->size());

    if (val == UNDEF)
      {
	state_bit->set_bit(n, false);
      }
    else
      {
	state_bit->set_bit(n);
	if (val == FALSE)
	  {
	    value_bit->set_bit(n, false);
	  }
	else 
	  {
	    value_bit->set_bit(n);
	  }
      }
  }

private:
  BitMagic* value_bit;
  BitMagic* state_bit;
};


typedef std::vector<BeliefSet*> BeliefState;

int main()
{
  
}
